<template>
  <el-breadcrumb :separator-icon="ArrowRight" id="content-title" class="breadcrumb">
    <el-breadcrumb-item
      v-for="(item, index) in pagData"
      :key="index"
      :to="index !== pagData.length - 1 ? { path: item.router } : undefined"
      class="breadcrumb-item"
    >
      <span
        class="crumb"
        :class="{ 'crumb-current': index === pagData.length - 1 }"
        :title="item.name"
      >
        {{ item.name }}
      </span>
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script setup lang="ts">
import type { PagingData } from '@/type/global'
import { ArrowRight } from '@element-plus/icons-vue'

defineProps<{
  pagData: PagingData[]
}>()
</script>

<style scoped>
#content-title {
  font-size: 18px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.breadcrumb-item :deep(.el-breadcrumb__inner) {
  display: inline-flex;
}

.crumb {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background-color: var(--el-fill-color-lighter);
  color: var(--el-text-color-regular);
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 0 0 1px var(--el-border-color-lighter) inset;
}

.breadcrumb-item :deep(.is-link) .crumb:hover {
  background-color: var(--el-fill-color);
  color: var(--el-color-primary);
  box-shadow: 0 0 0 1px var(--el-color-primary-light-7) inset;
}

.crumb-current {
  background-color: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--el-color-primary-light-5) inset;
}

:deep(.el-breadcrumb__separator) {
  margin: 0 8px;
  color: var(--el-text-color-placeholder);
}

@media (max-width: 768px) {
  .crumb {
    max-width: 140px;
    padding: 4px 8px;
    font-size: 14px;
  }
}
</style>
